<?php
/*
 * Created on 30 sept. 2010
 * Created by Ludovic Reenaers
 * lreenaers@hotmail.com
 */
class ModelLanguage extends Model{
	function change(){
		$dao= $this->daoFactory->getLangueDAO();
		$lngBean = $dao->getByIso($this->params[3]);
			
		$_SESSION["langue"] = $lngBean->getIso();
			
			
		if($_SESSION['USER_BEAN']->getProfile()->getLabel()<>"anonymous"){

			$_SESSION['USER_BEAN']->setLangue($lngBean);
			$usrdao= $this->daoFactory->getUserDAO();
			$usrdao->update($_SESSION['USER_BEAN']);
		}
		setcookie($_SESSION['config']->sitename.'[langue]', $this->params[3]);
		if (count($this->params)>=5){
			$retUrl = $_SESSION['config']->controler."?".str_replace("{{-}","/",$this->params[4]);
		}else{
			$retUrl = $_SESSION['config']->controler."?/homepage/show/";
		}
		return $retUrl;
	}
}
?>
